package com.qingke.easyjava;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App {
	
	
	
    public static void main( String[] args )throws SQLException
    {
        System.out.println( "App Start!" );
        
	    ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		
		HelloWorldBean bean=ctx.getBean("helloWorld",HelloWorldBean.class);
		bean.sayHello();
		
		BaseDao baseDao=(BaseDao)ctx.getBean("baseDao");
		System.out.println("connection from baseDao:"+baseDao.getConnection());
		
		DataSource ds=(DataSource)ctx.getBean("dataSource");
		Connection conn =ds.getConnection();
		
		System.out.println("connection from dataSource"+conn);
		
		DataSource ds2=(DataSource)ctx.getBean("dataSource2");
		System.out.println("connction from datasource2:"+ds2.getConnection());
		
		DataSource ds3=(DataSource)ctx.getBean("dataSource3");
		System.out.println("connction from datasource2:"+ds3.getConnection());
    }
}
